package com.xinzhi.mapper;

import com.xinzhi.pojo.LoanInterest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface LoanInterestMapper {

    @Insert("INSERT INTO loan_interest (Lxbz, dk_zh, dk_ye, Fxksrq, Lxdqrq, Lxjxrq, Lxclrq, Ll, Lxe, lxclbz) " +
            "VALUES (#{interestFlag}, #{loanAccount}, #{loanBalance}, #{interestStartDate}, " +
            "#{interestDueDate}, #{interestCalculationDate}, #{interestProcessingDate}, #{interestRate}, " +
            "#{interestAmount}, #{interestProcessingFlag})")
    void insert(LoanInterest loanInterest);

    @Update("UPDATE loan_interest " +
            "SET Lxbz = #{interestFlag}, dk_zh = #{loanAccount}, dk_ye = #{loanBalance}, " +
            "Fxksrq = #{interestStartDate}, Lxdqrq = #{interestDueDate}, Lxjxrq = #{interestCalculationDate}, " +
            "Lxclrq = #{interestProcessingDate}, Ll = #{interestRate}, Lxe = #{interestAmount}, " +
            "lxclbz = #{interestProcessingFlag} " +
            "WHERE lx_id = #{id}")
    void updateLoanInterest(LoanInterest loanInterest);

    @Delete("DELETE FROM loan_interest WHERE lx_id = #{id}")
    void deleteLoanInterest(@Param("id") Integer id);

    @Select("SELECT * FROM loan_interest WHERE lx_id = #{id}")
    LoanInterest selectLoanInterestById(@Param("id") Integer id);

    @Select("SELECT * FROM loan_interest")
    List<LoanInterest> selectAllLoanInterests();

    @Select("SELECT * FROM loan_interest WHERE dk_zh = #{loanAccount}")
    List<LoanInterest> getLoanInterestsByLoanAccount(@Param("loanAccount") String loanAccount);
}
